import { http, ResponseData } from '../http'
import { AxiosPromise } from 'axios'
 
interface IQuery {
  page?: number;
  pageSize?: number
}

// 获取列表
export const getList = (data: IQuery): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'GET',
    url: '/v1/article',
    data,
  })
}

// 删除
export const deleteById = (id: any): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'DELETE',
    url: `/v1/article/${id}`,
  })
}

// 添加
export const add = (data: any): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'POST',
    url: '/v1/article',
    data,
  })
}

// 编辑
export const edit = (data: any): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'PUT',
    url: '/v1/article',
    data,
  })
}

// 获取详情
export const getDetail = (id: any): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'GET',
    url: `/v1/article/${id}`,
  })
}

// 月度浏览量统计
export const getMonthlyView = (): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'GET',
    url: '/v1/articleMonthlyPv',
  })
}

// 月度文章数量统计
export const getMonthlyCount = (): AxiosPromise<ResponseData> => {
  return http.request({
    method: 'GET',
    url: '/v1/articleMonthlyCount',
  })
}
